package com.my.controller;


import com.alibaba.fastjson.JSONObject;
import com.my.bean.*;
import com.my.service.StockService;
import com.my.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * <p>
 * 库存剩余 前端控制器
 * </p>
 *
 * @author 崔倩倩
 * @since 2018-08-26
 */
@Controller
@RequestMapping("/stock")
public class StockController {

    @Autowired
    StockService stockService;

    //查询
    @RequestMapping("/selectStock")
    @ResponseBody
    public ResultPage<Stock> selectStock(VoPage voPage, HttpSession session) {
        boolean admin=false;
        //如果事超级管理员  即可查看所有的房间  判断是否为超级管理员
        if(SessionUtil.getSessionUser(session).getRoles().getRoleValue().equals("9f77d5a8-75c6-4d06-adf9-a37e727d491a")){
            admin=true;
        }
        Long areaid = ((User)session.getAttribute("user")).getAreaId();
        ResultPage<Stock> list = stockService.selectMyPage(voPage,areaid,admin);
        return list;
    }
    @RequestMapping("/stock")
    public String stock(){
        return "stock";
    }
}





